const express = require("express");
const blog = express.Router();
const auth = require("../../middleware/auth");
const { addRules, detailRules } = require("../../verify/blog");
const { listRules, addCRules } = require("../../verify/comment");
const { AddBlog, DetailBlog, DelBlog } = require("../../controller/blog");
const { AddComment, ListComment } = require("../../controller/comment");

// 添加博客
blog.post("/", auth, addRules, AddBlog);

// 博客详情
blog.get("/:id", detailRules, DetailBlog);

// 删除博客
blog.delete("/:id", auth, DelBlog);

// 博客对应的评论列表
blog.get("/:id/comment", listRules, ListComment);

// 评论
blog.post("/:id/comment", auth, addCRules, AddComment);

module.exports = blog;
